package com.huluobo.greendaodemo;

import android.app.Application;
import android.database.sqlite.SQLiteDatabase;

import com.huluobo.greendaodemo.db.DaoMaster;
import com.huluobo.greendaodemo.db.DaoSession;

public class App extends Application {
    private DaoSession daoSession;

    @Override
    public void onCreate() {
        super.onCreate();
        DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "user.db");//创建数据库名字和帮助类
        SQLiteDatabase db = helper.getWritableDatabase();//拿到具体的数据库本体
        DaoMaster daoMaster = new DaoMaster(db);//通过master创建数据库
        daoSession = daoMaster.newSession();//通过session可以对数据库进行增删改查
    }

    public DaoSession getDaoSession() {
        return daoSession;
    }
}
